package org.joe.chinachess.net;

import java.io.File;
import java.io.FileInputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/**
 * 飞秋截取
 * 
 * @author Joe
 * 
 */
public class Server {

	public static void main(String[] args) throws Exception {
		String path = "src/"
				+ Server.class.getPackage().getName().replaceAll("\\.", "/")
				+ "/" + Server.class.getSimpleName() + ".java";
		System.out.println(path);
		DatagramSocket ds = new DatagramSocket();
		File f = new File(path);
		Scanner sc = new Scanner(new FileInputStream(f));
		StringBuffer sb = new StringBuffer();
		while (sc.hasNextLine()) {
			String line = sc.nextLine();
			sb.append(line);
			sb.append("\n");
		}
		String text = sb.toString();
		DatagramPacket dp = new DatagramPacket(
				("1:100:要你命三千:黑山老妖:32:" + text + "").getBytes(),
				("1:100:要你命三千:黑山老妖:32:" + text + "").getBytes().length,
				InetAddress.getByAddress(new byte[] { 88, 1, 16, (byte) 100 }),
				2425);
		ds.send(dp);
	}
}
